package com.bjpowernode.springboot.utils;

import com.bjpowernode.springboot.entity.UserBean;

import java.lang.reflect.Field;
import java.util.HashMap;

/**
 * 实体Bean工具类
 */
@SuppressWarnings("all")
public class UserBeanUtils {

    /**
     * 封装UserBean实体的成员属性
     * @param object: 被封装的对象
     * @param args：封装的属性
     */
    public static void UserBeanPopulate(Object object, HashMap<String, Object> map) {
        // 判断object是否是UserBean属于同一个类
        if (!(object instanceof UserBean)) throw new ClassCastException();
        UserBean userBean = (UserBean) object; // 强制转化为UserBean
        userBean.setUsername((String) map.get("username"));
        userBean.setPassword((String) map.get("password"));
    }
}
